package com.scs.application.modules.base.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.model.CommonResult;
import com.scs.application.core.model.PageResult;
import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.core.mvc.controller.ImAndExAbleController;
import com.scs.application.modules.base.entity.HospitalThirdPlatform;
import com.scs.application.modules.base.request.HospitalThirdPlatformQueryRequest;
import com.scs.application.modules.base.service.HospitalThirdPlatformService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 第三方配置 controller
 */
@AllArgsConstructor
@RestController
@RequestMapping("/hospital_third_platforms")
public class HospitalThirdPlatformController extends CrudController<HospitalThirdPlatform, String, HospitalThirdPlatformService> implements ImAndExAbleController<HospitalThirdPlatformQueryRequest> {

    @GetMapping("/page")
    public PageResult page(HospitalThirdPlatformQueryRequest request) {
        IPage page = service.page(request);
        return PageResult.ok("查询成功", page.getRecords(), page.getTotal());
    }

    @GetMapping("/list")
    public CommonResult list(HospitalThirdPlatformQueryRequest request) {
        List<HospitalThirdPlatform> list = service.list(request);
        return CommonResult.ok("查询成功", list);
    }

//    @PostMapping("/test")
//    public CommonResult test(@RequestBody @Valid HospitalThirdPlatform hospitalThirdPlatform ) {
//        return thirdPlatformClient.test(hospitalThirdPlatform);
//    }

    @Override
    @PostMapping
    public CommonResult add(@RequestBody @Valid HospitalThirdPlatform entity) {
        CommonResult result = super.add(entity);
        return result;
    }

    @PutMapping
    public CommonResult update(@RequestBody @Valid HospitalThirdPlatform entity) {
        CommonResult result = super.update(entity);
        return result;
    }

    @DeleteMapping({"/{id}"})
    public CommonResult deleteById(@PathVariable("id") String id) {
        CommonResult result = super.deleteById(id);
        return result;
    }
}
